package com.ruoyi.web.controller.fx;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.fx.FxServeCategory;
import com.ruoyi.system.domain.vo.FxServeCategoryVo;
import com.ruoyi.system.service.fx.IFxServeCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 预约服务分类
 *
 * @author ruoyi
 * @date 2025-04-27
 */
@RestController
@RequestMapping("/system/serveCategory")
public class FxServeCategoryController extends BaseController
{
    @Autowired
    private IFxServeCategoryService fxServeCategoryService;

    /**
     * 查询预约服务分类列表
     * @return {@link FxServeCategory}
     */
    @GetMapping("/list")
    public TableDataInfo list(FxServeCategory fxServeCategory)
    {
        startPage();
        List<FxServeCategoryVo> list = fxServeCategoryService.selectFxServeCategoryList(fxServeCategory);
        return getDataTable(list);
    }

    /**
     * 导出预约服务分类列表
     */
    @Log(title = "商品分类", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FxServeCategory fxServeCategory)
    {
        List<FxServeCategoryVo> list = fxServeCategoryService.selectFxServeCategoryList(fxServeCategory);
        ExcelUtil<FxServeCategoryVo> util = new ExcelUtil<FxServeCategoryVo>(FxServeCategoryVo.class);
        util.exportExcel(response, list, "商品分类数据");
    }



    /**
     * 获取预约服务分类详细信息
     * @return {@link FxServeCategory}
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(fxServeCategoryService.selectFxServeCategoryById(id));
    }

    /**
     * 新增预约服务分类分类
     */
    @Log(title = "商品分类", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FxServeCategory fxServeCategory)
    {
        return toAjax(fxServeCategoryService.insertFxServeCategory(fxServeCategory));
    }

    /**
     * 修改预约服务分类分类
     */
    @Log(title = "商品分类", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FxServeCategory fxServeCategory)
    {
        return toAjax(fxServeCategoryService.updateFxServeCategory(fxServeCategory));
    }

    /**
     * 删除预约服务分类分类
     */
    @Log(title = "商品分类", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fxServeCategoryService.deleteFxServeCategoryByIds(ids));
    }



}
